const Collections = require('../models/collections');
var moment = require('moment');

exports.collect= function(req, res) {
    var _col = req.body.col;

    var col = new Collections(_col);
    col.save(function(err,result){
        if(err){
            console.log(err)
        }
        if(result){
            return res.send("收藏成功")
        }
    })
};
exports.yan = function(req,res){
    var _id = req.body.id;
    Collections.findOne({id:_id},function(err,result){
        if(err){
            console.log(err)
        }else if(!result){
            return res.send("未收藏")
        }else if(result){
            return res.send("已收藏")
        }
    })
};
exports.Dcollect = function(req,res){
    var _id = req.body.id;
    Collections.remove({id:_id},function(err,result){
        if(err){
            return console.log(err);
        }
        if(result){
            return res.send("删除成功");
        }
    })
}
//查询我的收藏列表
exports.cList = function(req,res){
    var collect_man = req.body.data;
    Collections.find({'collect_man':collect_man},function(err,result){
        if(err){
            return console.log(err)
        }
        return res.send(result)
    })
};